home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10272 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.5 KB  |  84 lines

  1. Path: EU.net!sun4nl!xs4all!falstaff
  2. From: falstaff@xs4all.nl (Falstaff)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Bizarre error with structures, please help!
  5. Date: 16 Mar 1996 13:02:09 GMT
  6. Organization: XS4ALL, networking for the masses
  7. Message-ID: <4iee4h$a7u@news.xs4all.nl>
  8. References: <4idkfo$1el@news.voicenet.com>
  9. NNTP-Posting-Host: xs1.xs4all.nl
  10. X-Newsreader: NN version 6.5.0 #666 (NOV)
  11.  
  12. deaton@cygnus.rsabbs.com writes:
  13.  
  14.  
  15. >typedef struct 
  16. >{
  17. >   char type[20];  //Weapon name.
  18. >   int  cost;        //Cost of weapon in Gold.
  19. >   int  damhi;     //High range of damage for the weapon.
  20. >   int  damlo;     //Low range of damage for the weapon.
  21. >   int  wtype;     //Numerical weapon reference.
  22. >   int  missle;     //Is the weapon a missle weapon? (1 or 0)
  23. >   char size;      //'S'mall or 'L'arge. No shield with large.
  24. >   int  actual;    //Actual damage done directly to a unit.
  25. >   int  special;   //Special case damage. If 1, actual damage ammount is dealt
  26. >                       //to the armor, and remainder is done to the unit.
  27. >}weaponS;
  28.  
  29. >static weaponS w[WEP_REF];
  30.  
  31. >main()
  32. >{//MAIN
  33.  
  34. >   register int count;
  35. >   FILE * fptr;
  36. >   printf("\n\n\n\n\n\n\Populating Structure.");
  37.  
  38. >   strcpy(w[0].type,"Dagger");
  39. >   w[0].cost=0;
  40. >   w[0].size='s';
  41. >   w[0].wtype=0;
  42. >   w[0].damhi=4;
  43. >   w[0].damlo=1;
  44. >   w[0].actual=1;
  45. >   w[0].special=0;
  46. >   w[0].missle=0;
  47.  
  48. >   putch('.');
  49.  
  50. >   strcpy(w[1].type,"Sabre");
  51. >   w[1].cost=0;
  52. >   w[1].size='s';
  53. >   w[1].wtype=1;
  54. >   w[1].damhi=5;
  55. >   w[1].damlo=2;
  56. >   w[1].actual=1;
  57. >   w[1].special=0;
  58. >   w[1].missle=0;
  59.  
  60.  
  61. Why aren't you using this?  BASIC/Pascal background, perhaps?
  62.  
  63. struct weapons
  64. {
  65.    char *type;     /* Weapon name (CHANGED TO PTR)        */
  66.    int  cost;      /* Cost of weapon in Gold.            */
  67.    int  damhi;     /* High range of damage for the weapon.    */
  68.    int  damlo;     /* Low range of damage for the weapon.    */
  69.    int  wtype;     /* Numerical weapon reference.        */
  70.    int  missle;    /* Is the weapon a missle weapon? (1 or 0)    */
  71.    char size;      /* 'S'mall or 'L'arge. No shield with large.    */
  72.    int  actual;    /* Actual damage done directly to a unit.    */
  73.    int  special;   /* Special case damage.            */
  74. } weapons[] =        /* No need to specify count here */
  75. {  
  76.    {  "Dagger",0,'S',0,4,1,1,0,0 },
  77.    {  "Sabre", 0,'S',1,5,2,1,0,0 },
  78.    /* etc */
  79. };
  80. --
  81. The famous GIICM now on line:  http://www.xs4all.nl/~falstaff/GIICM.html
  82. ------------------------------------------------------------------------
  83. Frank A. Vorstenbosch        +31-(70)-355 5241        falstaff@xs4all.nl
  84.